<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!--#include file="includes/common.aspx"-->
<!--#include file="includes/includeitems.aspx"-->
<script  runat="server">
Dim strInterest="",SQL="",j=0,strItems=""
Dim continue="",file="",fromcart="",submitcarts=""
Dim i=0,liSession=0,No=1,isOK=True,strSession=""
Dim Amount=0
Dim ItemName=""
Dim AuthorName=""
Dim Quantity=0
Dim SalesPrice=0
Dim ItemStyle=""	
Dim ItemID=""
Dim ProName=""
Dim ListPrice=0
Dim SalesDiscount=0
Dim Weight=""
Dim Available=""
Sub Page_Load(ByVal sender As Object, _
	ByVal e As EventArgs)	
   If Not Page.IsPostback Then
	file=request.querystring("from_")
	fromcart=Request.Form("fromcart")		
	submitcarts=Request.Form("submit-carts")	
	continue ="id="  + request.querystring("id")
	continue += "&rows=" + Request.querystring("rows")
	continue += "&pages=" + request.querystring("pages")
	continue +="&page=" + request.querystring("page")
	continue += "&sort=" + request.querystring("sort")
	continue += "&from_=" + request.querystring("from_")		
	if file="" then file="search.aspx"
	if session("shoppingcart")>0 then					
		i=0:No=1:isOK=True:strSession="":liSession=0										
		if submitcarts="Update" then						
			if fromcart="1" then
				i=1
				if   request.form("itemqtty"  +  i.toString()) <>"" and  request.form("itemqtty"  +  j.toString()) >"0" then
					strItems=i.toString()
					strSession= "{"  +  strItems  +  "itemid="  +   request.form("itemid"  +  strItems)   +  "}{itemname"  +  strItems+  "="  +  _
					request.form("itemname"  +  strItems)  +  "}{itemprice"  +  strItems + "="  +  request.form("itemprice"  +  strItems)  +  _
					"}{itemqtty"  +  strItems +  "="  +  request.form("itemqtty"  +  strItems)    +  "}{itemdiscount"  +  strItems +  "="  +  _
					request.form("itemdiscount"  +  strItems)     +  "}{itemweight"  +  strItems +  "="  +  request.form("itemweight"  +  strItems)    + _
					 "}{itemlistprice"  +  strItems +  "="  +  request.form("itemlistprice"  +  strItems)    +  "}{itemstyle"  +  strItems +  "="  +  _
					request.form("itemstyle"  +  strItems)    +  "}{itemproname"  +  strItems +  "="  +  request.form("itemproname"  +  strItems)    +  _
					"}{itemauthorname"  +  strItems +  "="  +  request.form("itemauthorname"  +  strItems)    +  "}{itemavailable"  +  strItems +  "="  +  _
					request.form("itemavailable"  +  strItems)    +  "}{itemimage"  +  strItems +  "="  +  request.form("Image"  +  strItems)  +  "}"
					liSession=1
					if not isnumeric(request.form("itemqtty"  +  strItems)) then isOK=false
				else
					liSession=0
				end if						
			elseif fromcart >= "2" then							
				for j =1 to session("shoppingcart")	
					strInterest=j.toString()
					if   request.form("itemqtty"  + strInterest)<>""  and  request.form("itemqtty"  + strInterest)>"0" then
						i=i+1
						strItems=i.toString()									
						strSession= strSession  +  "{"  +  strItems  +  "itemid="  +   request.form("itemid"  +  strInterest)   +  "}{itemname"  +  strItems +  "="  +  _
						request.form("itemname"  +  strInterest)   +  "}{itemprice"  +  strItems  + "="  +  request.form("itemprice"  +  strInterest)  +  _
						"}{itemdiscount"  +  strItems  + "="  +  request.form("itemdiscount"  +  strInterest)   +  "}{itemweight"  + strItems   +  "="  +  _
						request.form("itemweight"  +  strInterest)  +  "}{itemqtty"  +  strItems   +  "="  +  request.form("itemqtty"  +  strInterest)    +  _
						"}{itemlistprice"  +  strItems  +  "="  +  request.form("itemlistprice"  +  strInterest)    +  "}{itemstyle"  + strItems  +  "="  +  _
						request.form("itemstyle"  +  strInterest)    +  "}{itemproname"  +  strItems   +  "="  +  request.form("itemproname"  +  strInterest)    +  _
						"}{itemauthorname"  + strItems  +  "="  +  request.form("itemauthorname"  +  strInterest)    +  "}{itemavailable"  +  strItems   +  "="  +  _
						request.form("itemavailable"  +  strInterest)    +  "}{itemimage"  +  strItems   +  "="  +  request.form("Image"  +  strInterest)  +  "}"						
						if not isnumeric(request.form("itemqtty"  +  strInterest)) then isOK=false
					end if								
				next
				liSession=i
			end if
			if (isOK=True) then
				session("shoppingcarts")=strSession
				session("shoppingcart")=liSession							
			end if
		elseif submitcarts="Remove" then
			session("shoppingcart")=0
			session("shoppingcarts")=""										
		end if
		SQL="select ItemID as No, "
		SQL = SQL & "ItemName As Name, "
		SQL = SQL & "AuthorName As AuthorName, AuthID,SubCateID,"
		SQL = SQL & "ItemStyle "					
		SQL = SQL & "from vwItems where ItemID not in ('" & replace(strItems,",","','") & "')"
		SQL = SQL & " and  ItemID in "						
		SQL = SQL & " (select ItemID from vwOrderIDs "
		SQL = SQL & " where OrderID in (select OrderID "
		SQL = SQL & " from vwOrderIDs where ItemID not in ('"
		SQL = SQL &  replace(strItems,",","','") & "')))"
		SQL = SQL & " order by CustomerRating ,ItemName ASC"
		'response.write(SQL)		
		strInterest=includeitems(SQL ,"details.aspx",1,"","&" & continue)
	end if
     end if
End Sub
</script>
<HTML><HEAD><TITLE>InterShop-Online Shopping</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<META content=""  name=description>
<META content="trading software platform" name=keywords>
<META http-equiv=Pragma content=no-cache>
<LINK href="style.css" type=text/css rel=stylesheet>
<SCRIPT language=JavaScript>
        	self.defaultStatus = "Online-Shopping!";                           
</SCRIPT>
<SCRIPT LAGUAGE=JAVASCRIPT>
function result(i)
{
	document.frmView.page.value=i;
	document.frmView.submit();
}
function checkinput()
{	var x="";isOK=true;
	for (var i=0; i<document.frmView.elements.length;i++)
	{
	x=document.frmView.elements[i].name;	
	if(x.indexOf("qtty")!=-1)
		{			
			if (!parseInt(document.frmView.elements[i].value) && document.frmView.elements[i].value!="0" ) 
				isOK=false;
		}
	}
	if (!isOK)
		alert("Sorry, invalid quantity! \n In case of delete this Item, \n you can check on checkbox");
	return isOK;
}
</SCRIPT>
</HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0  rightMargin=0 marginheight="0"  marginwidth="0">
<!--#include file="top.aspx"-->
<TABLE cellSpacing=0 cellPadding=0 border=0  width="775" >
  <TBODY> 
  <TR>
    <TD vAlign=top height="508" width="160" align="center"> 
      <table width="18%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="center"><br> 
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/interhop-seacrh.gif" height="19" width="155"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% height="49"> 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" height="51" bgcolor="#EEEECC"> 
                              <table cellspacing=0 cellpadding=0 border=0  width="100%">
                                <tr> 
                                  <td colspan=2>&nbsp;</td>
                                </tr>
                                <tbody> 
                                <tr  align="left"> 
                                  <td colspan=2> 
                                    <input size=15  onFocus="this.value = '';" value="Keyword" name=txtKeyword class=textbox>
                                  </td>
                                </tr>
                                <tr> 
                                  <td align=left> 
                                    <select name="cbCate">
                                      <option selected>All Products</option>
                                      <option>Books</option>
                                      <option>Poems</option>
                                    </select>
                                    <img height=21 
            alt="Click here to search the Item." 
            src="images/go.gif" 
            width=21 align=absMiddle 
      border=0></td>
                                </tr>
                                </tbody> 
                              </table>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
      <table width="18%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td align="center"><br>
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/web-search.gif" height="19" width="155"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% > 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" bgcolor="#CAE2F0"> 
                              <input size=15  onFocus="this.value = '';" value="Keyword" name=txtKeyword2 class=textbox>
                              <img height=21 
            alt="Click here to search the Item." 
            src="images/go-button.gif" 
            width=21 align=absMiddle 
      border=0> <br>
                              <img src="images/powered-by-google.gif" width="95" height="14"> 
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
      <table width="18%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td align="center"><br>
            <table border=0 cellspacing=0 cellpadding=0>
              <tr valign=bottom align=center> 
                <td><img src="images/browse-items.gif" width="155" height="19"></td>
              </tr>
              <tr valign=top align=center> 
                <td> 
                  <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                    <tr> 
                      <td width=100% height="49"> 
                        <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                          <tr> 
                            <td valign=top width=8% align="left" height="51" bgcolor="#CAE2F0"> 
                              <!--#include file="includes/listsubcategories.htm"-->
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
            </table>
      </table>
      <!--#include file="left.aspx"-->
    </TD>
    <TD class=margin width="1" valign="top" align="right" bgcolor="#666666" > 
    </TD>
    <TD class=text_normal id=mainContent vAlign=top height="508" width="420"> 
      <TABLE cellSpacing=4 cellPadding=4 width="100%" align=left border=0 height="61">
        <TR> 
          <TD vAlign=top align=left height="42"> 
            <!--#include file="submenu.aspx"--><br>
	<img src="images/yourcart.gif">
          </TD>
       
        <TBODY> 
        <TR> 
          <TD vAlign=top align=middle height="207"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <%
	if session("shoppingcart")>0 then
	%>
              <form action="viewcart.aspx?<%=continue%>" method="post" name="frmView" onsubmit="return checkinput();">
                <tr bgcolor="#CCCCCC"> 
                  <td valign="middle" height="26" width="9%"><b> </b></td>
                  <td valign="middle" height="26" width="62%"><b>Shopping Cart 
                    Items--To Buy Now</b></td>
                  <td width="23%" valign="middle" height="26" align="center"><b>Quantity</b></td>
                 
                </tr>
                <tr> 
                  <td width="9%" valign="top">&nbsp;</td>
                  <td width="62%" valign="top">&nbsp;</td>
                  <td width="23%" valign="top">&nbsp;</td>
                  
                </tr>
                <%
												
	Amount=0:SalesDiscount=0											
	for No = 1 to session("shoppingcart")
	  ItemID=Seperate(session("shoppingcarts"),No & "itemid" )					   
	  strItems=strItems +ItemID + ","
	  ItemName=Seperate(session("shoppingcarts"),"itemname" & No) 
	  AuthorName=Seperate(session("shoppingcarts"),"itemauthorname" & No) 
	  ProName=Seperate(session("shoppingcarts"),"itemproname" & No) 
	  ListPrice=Seperate(session("shoppingcarts"),"itemlistprice" & No)
	  Quantity=Seperate(session("shoppingcarts"),"itemqtty" & No)
	  SalesPrice=Seperate(session("shoppingcarts"),"itemprice" & No)  
	  SalesDiscount=Seperate(session("shoppingcarts"),"itemdiscount" & No)  
	  Weight=Seperate(session("shoppingcarts"),"itemweight" & No)  
	  Available=Seperate(session("shoppingcarts"),"itemavailable" & No) 
	  ItemStyle=Seperate(session("shoppingcarts"),"itemstyle" & No) 
	  Amount=Amount+SalesPrice*Quantity
	%>
                <tr> 
                  <td width="9%" valign="top" align="center">
	   <img src="icons/small-blue-books-icon.gif" 
		width="18" height="18"></td>
                  <td width="62%" valign="top"> <b>
	   <a href="details.aspx?itemid=<%=ItemID%>&<%=continue%>">
	   <font face="Arial"><%=ItemName%></font></a></b><br>
                    <strong><%=AuthorName%></strong><br>
                    Nhà xuất bản: <%=ProName%><br>
                    Giá bìa: <%=FormatNumber(ListPrice,0)%> 
		Giảm giá: <%=FormatNumber(ListPrice-SalesPrice,0)%><br>
                    Giá bán: <%=FormatNumber(SalesPrice,0)%> 
		Kiểu bìa: <%=ItemStyle%> <br>
                    <%=Available%> <br>
                  </td>
                  <td width="23%" valign="top" align="center"> 
                    <input type="text" name="itemqtty<%=No%>" 
		size="5" class=textbox value="<%=Quantity%>">
                    <br>
                    <input type=hidden name="itemid<%=No%>" 
		value="<%=ItemID%>">
                    <input type=hidden name="itemname<%=No%>" 
		value="<%=ItemName%>">
                    <input type=hidden name="itemauthorname<%=No%>" 
		value="<%=AuthorName%>">
                    <input type=hidden name="itemproname<%=No%>" 
		value="<%=ProName%>">
                    <input type=hidden name="itemstyle<%=No%>" 
		value="<%=ItemStyle%>">
                    <input type=hidden name="itemavailable<%=No%>" 
		value="<%=Available%>">
                    <input type=hidden name="itemprice<%=No%>" 
		value="<%=SalesPrice%>">
	      <input type=hidden name="itemdiscount<%=No%>" 
		value="<%=SalesDiscount%>">
	     <input type=hidden name="itemlistprice<%=No%>" 
		value="<%=ListPrice%>">
                    <input type=hidden name="itemweight<%=No%>" 
		value="<%=Weight%>">
                  </td>
                  
                </tr>
                <tr> 
                  <td height="19" colspan="3"> 
                    <hr noshade size="1" color=gray>
                  </td>
                </tr>
                <%
	next  			 
	%>
                <input type=hidden name="fromcart" 
	value="<%=session("shoppingcart")%>">
                <tr valign="top"> 
                  <td height="36" colspan="3" align="right"> 
                    <table width="100%" border="0" 
		cellspacing="0" cellpadding="0">
                      <tr valign="middle"> 
                        <td align="center" height="35"> 
                          <input type=image src="images/update-01.gif" 
		width="48" height="14" align="middle">
                          <b> your shopping cart.</b></td>
                        <td align="right" width="27%" height="35"><b> 
                          <input type=hidden name="submit-carts" 
		value="Update">
                          Subtotal: <font color=red></font></b></td>
                        <td align="right" width="23%" nowrap height="35">
		<b><font color=red>VND 
                          <%=FormatNumber(Amount,0)%></font></b></td>
                      </tr>
                    </table>
                    <b></b></td>
                </tr>
              </form>
              <tr> 
                <td height="19" colspan="3" align="right"> 
                  <hr noshade size="1" color=gray>
                </td>
              </tr>
              <tr> 
                <td height="19" width="9%" align="right">&nbsp;</td>
                <td height="19" width="62%" align="left" valign="middle"> <a href="preorder.aspx?<%=continue%>">
	<img src="images/order-to-cart.gif" width="95" height="20" border="0"></a> 
                  <a href="search.aspx?<%=continue%>"><img src="images/search.gif" width="80" height="19" border="0"></a></td>
                <form action="viewcart.aspx" method="post" name="frmReset">
                  <td height="19"  align="right" valign="middle"> 
                    <input type=hidden name="submit-carts" value="Remove">
                    <input type=image src="images/reset.gif" width="80" height="19"> </td>
                </form>
              </tr>
              <tr> 
                <td height="19" colspan="3" align="right"> 
                  <hr noshade size="1" color=gray>
                </td>
              </tr>
              <%end if			
	
	 if session("shoppingcart")>0 then
		
		if strInterest<>"" then
			  %>
              	<tr align="left"> 
                	<td height="28" colspan="4"><b>Customers who bought the items 
                 	 in <font color=red face="Arial" >your shopping cart</font> also 
                 	 bought:</b></td>
            	 	 </tr>
            		  <tr align="left"> 
                		<td height="19" colspan="4"> 
                		  <%													
			response.write(strInterest)
			%>
               	 </td>
              	</tr>
              	<tr align="left"> 
                	<td height="19" colspan="4"> 
                  	<hr noshade size="1" color=gray>
               	 </td>
            	  	</tr>
              	<%end if
	else%>
              <tr align="left"> 
                <td height="28" colspan="3"> 
                  <hr noshade size="1" color=gray>
                </td>
              </tr>
              <tr align="center"> 
                <td height="74" colspan="3"> 
                  <p><b> <font color=red>Oops!  Your shopping is either empty or has expired.  
	<br>Please go to our home to start shopping.

                    </font></b></p>
                  <p><a href="<%=file%>?<%=continue%>"><img src="images/search.gif" width="80" height="19" border="0"></a></p>
                </td>
              </tr>
              <tr align="left"> 
                <td height="28" colspan="3"> 
                  <hr noshade size="1" color=gray>
                </td>
              </tr>
              <%
	end if%>
              <tr align="left"> 
                <td height="33" colspan="3">You can save items here to buy later. 
                  When you're ready to buy any of your saved items, just move 
                  them to your cart. </td>
              </tr>
              <tr align="left"> 
                <td height="27" colspan="3"><b>About the Shopping Cart</b> </td>
              </tr>
              <tr align="left"> 
                <td height="19" colspan="3"><br>
                  Items in your Shopping Cart always reflect the most recent price 
                  displayed on their product pages. <br>
                  Items remain in your Shopping Cart for 90 days. <br>
                  Learn more about the Shopping Cart and how to buy items at InterShop.com. 
                  <br>
                </td>
              </tr>
              <tr align="left"> 
                <td height="19" colspan="3">&nbsp;</td>
              </tr>
              <tr align="left"> 
                <td height="19" colspan="3">&nbsp;</td>
              </tr>
            </table>
          </TD>
        </TR>
        </TBODY> 
      </TABLE>
    </TD>
    <TD class=margin width="1" valign="top" align="right" bgcolor="#666666" height="508"> 
    </TD>
    <TD class=margin valign="top" align="center" height="508" width="160"> 
      <table align="center">
        <tr> 
          <td >&nbsp;</td>
          <td valign="top" align="center" >&nbsp;</td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td valign=top align="center"> 
            <!--#include file="includes/right-next.htm" -->
          </td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td valign=top align="center"> <br>
            <table width="18%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td align="center"> 
                  <table border=0 cellspacing=0 cellpadding=0>
                    <tr valign=bottom align=center> 
                      <td><img src="images/top-products.gif" width="155" height="19"></td>
                    </tr>
                    <tr valign=top align=center> 
                      <td> 
                        <table border=0 width=155 cellpadding=1 cellspacing=0 bgcolor=#708090 >
                          <tr> 
                            <td width=100%> 
                              <table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#FFFFFF>
                                <tr> 
                                  <td valign=top width=8% align="left" height="52"> 
                                    <p>&nbsp;</p>
                                  </td>
                                  <td valign=top width=92% align="left" height="52"> 
                                    <!--#include file="includes/right-top.htm" -->
                                  </td>
                                </tr>
                              </table>
                            </td>
                          </tr>
                        </table>
                  </table>
            </table>
          </td>
        </tr>
      </table>
    </TD>
  </TR></TBODY></TABLE>
  <!--#include file="bottom.aspx"-->
</BODY></HTML>
